package com.ikas.ai.server.module.machine.enums;

import java.util.ArrayList;
import java.util.List;

public enum MachineInfoEnum {

    U01_ACTIVE_POWER("U01", "1CRK00_1MW_CAI", "activePower"), // 有功功率
    U01_REACTIVE_POWER("U01", "1CRK00_1VAR_CAI", "reactivePower"),
    U01_VANE_OPEN("U01", "1CRK00_MOR001_AO", "vaneOpen"),
    U01_SPEED("U01", "1CRK00_MVG001_AO", "speed"),

    U02_ACTIVE_POWER("U02", "2CRK00_1MW_CAI", "activePower"),
    U02_REACTIVE_POWER("U02", "2CRK00_1VAR_CAI", "reactivePower"),
    U02_VANE_OPEN("U02", "2CRK00_MOR001_AO", "vaneOpen"),
    U02_SPEED("U02", "2CRK00_MVG001_AO", "speed"),

    U03_ACTIVE_POWER("U03", "3CRK00_1MW_CAI", "activePower"),
    U03_REACTIVE_POWER("U03", "3CRK00_1VAR_CAI", "reactivePower"),
    U03_VANE_OPEN("U03", "3CRK00_MOR001_AO", "vaneOpen"),
    U03_SPEED("U03", "3CRK00_MVG001_AO", "speed"),

    U04_ACTIVE_POWER("U04", "4CRK00_1MW_CAI", "activePower"),
    U04_REACTIVE_POWER("U04", "4CRK00_1VAR_CAI", "reactivePower"),
    U04_VANE_OPEN("U04", "4CRK00_MOR001_AO", "vaneOpen"),
    U04_SPEED("U04", "4CRK00_MVG001_AO", "speed");

    private String machineNo;
    private String code;
    private String alias;

    MachineInfoEnum(String machineNo, String code, String alias) {
        this.machineNo = machineNo;
        this.code = code;
        this.alias = alias;
    }

    public String getMachineNo() {
        return machineNo;
    }

    public String getCode() {
        return code;
    }

    public String getAlias() {
        return alias;
    }


    public static List<String> getCodesByMachineNo(String machineNo) {
        List<String> codes = new ArrayList<>();
        for (MachineInfoEnum value : MachineInfoEnum.values()) {
            if (value.machineNo.equals(machineNo)) {
                codes.add(value.code);
            }
        }
        return codes;
    }

    public static MachineInfoEnum getByCode(String code) {
        List<String> codes = new ArrayList<>();
        for (MachineInfoEnum value : MachineInfoEnum.values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        throw new RuntimeException("无效code");
    }
}
